﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JiveMessenger.ViewModels;
using JiveMessenger.Models;
using System.Collections.ObjectModel;
using Windows.UI.Xaml;
using GalaSoft.MvvmLight.Command;

namespace JiveMessenger.SampleData
{
    class SampleViewModelManageGroup:IViewModelManageGroup
    {
        public RelayCommand<IGroupMember> RemoveUserCommand { get; set; }
        public RelayCommand<IChatGroup> RenameGroupCommand { get; set; }
        public RelayCommand<IChatGroup> DeleteGroupCommand { get; set; }
        public RelayCommand RefreshMembersCommand { get; set; }
        private IChatGroup _chatGroup;
        public Models.IChatGroup ChatGroup
        {
            get
            {
                //ViewModelLocator locator = (ViewModelLocator)Application.Current.Resources["Locator"];
                //return locator.ViewModelContactList.CurrentUser.ChatGroups.FirstOrDefault(x => x is JiveChatGroupModel);
                if (_chatGroup == null)
                {
                    var groupMembers = new Dictionary<string,JmShared.GroupPrivilege>();
                    groupMembers.Add("owner@gmail.com", JmShared.GroupPrivilege.Owner);
                    groupMembers.Add("test@gmail.com", JmShared.GroupPrivilege.Moderator);
                    groupMembers.Add("test2@gmail.com", JmShared.GroupPrivilege.Member);
                    _chatGroup = new JiveChatGroupModel("1", "Lulzfest", groupMembers);

                }
                return _chatGroup;
            }
            set
            {
                
            }
        }
        System.Collections.ObjectModel.ObservableCollection<Models.IGroupMember> _groupMembers;
        public System.Collections.ObjectModel.ObservableCollection<Models.IGroupMember> GroupMembers
        {
            get
            {
                if(_groupMembers == null)
                    _groupMembers = new ObservableCollection<IGroupMember>(((JiveChatGroupModel)this.ChatGroup).GroupMembers.Select(x => new JiveGroupMember(x.Key, "testnick", x.Value)));
                return _groupMembers;
            }
            set
            {
               
            }
        }
    }
}
